//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package org.apache.poi.xwpf.converter.core;

import org.apache.poi.util.IOUtils;

import java.io.*;

public class FileImageExtractor implements IImageExtractor {
    private final File baseDir;

    public FileImageExtractor(File baseDir) {
        this.baseDir = baseDir;
    }

    public void extract(String imagePath, byte[] imageData) throws IOException {
        File imageFile = new File(this.baseDir, imagePath);
        imageFile.getParentFile().mkdirs();
        InputStream in = null;
        FileOutputStream out = null;

        try {
            in = new ByteArrayInputStream(imageData);
            out = new FileOutputStream(imageFile);
            IOUtils.copy(in, out);
        } finally {
            if (in != null) {
                IOUtils.closeQuietly(in);
            }

            if (out != null) {
                IOUtils.closeQuietly(out);
            }

        }

    }
}
